package com.bdqn.controller;


import com.bdqn.entity.Comment;
import com.bdqn.service.CommentService;
import com.bdqn.util.Page;
import com.bdqn.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @GetMapping("/pageList")
    @ResponseBody
    public Result<Page<Comment>> loadComment(
        @RequestParam(name = "papgeIndex", defaultValue = "1") Integer pageIndex, String uuid) {

        return commentService.getPageComments(pageIndex, uuid);
    }

    @ResponseBody
    @PostMapping("/sendComment")
    public Result sendCommand(Comment comment, HttpSession session) {
        return commentService.addCommand(comment, session);
    }

}